<?php
// bootstrap.php

require_once(dirname(__FILE__). '/Base/Vendors/Firephp/fb.php');
require_once(dirname(__FILE__) . '/Base/Vendors/Doctrine/Doctrine.php');
require_once(dirname(__FILE__) . '/Base/Core.php');

spl_autoload_register(array('Qp_Core', 'autoload'));
spl_autoload_register(array('Doctrine_Core', 'autoload'));
spl_autoload_register(array('Doctrine_Core', 'modelsAutoload')); 


FB::setEnabled(Qp_Setup::DEBUG);
ob_start();

$manager = Doctrine_Manager::getInstance();

$manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
$manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL);
$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, Qp_Setup::DB_TABLE_PREFIX.'%s');

$conn = Doctrine_Manager::connection('mysql://'.Qp_Setup::DB_USER.':'.Qp_Setup::DB_PASSWORD.'@'.Qp_Setup::DB_HOST.'/'.Qp_Setup::DB_NAME);

$conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
$conn->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);

$conn->setCollate(Qp_Setup::DB_COLLATE);
$conn->setCharset(Qp_Setup::DB_CHARSET);

Doctrine_Core::loadModels(dirname(__FILE__).'/Base/Models');

Qp_Debug::addConnectionListener();
